* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*/
class SiteArray extends GenericArrayObject implements SiteList {
+ /**
+ * Update this version number when the SiteArray format
+ * changes in an incompatible way
+ *
+ * @since 1.21
+ *
+ * @var integer
+ */
+ const CACHE_VERSION = 1;
+
+ /**
+ * Version number of the SiteArray format of the currently used object
+ *
+ * @since 1.21
+ *
+ * @var integer
+ */
+ public $cacheVersion = self::CACHE_VERSION;
/**
* Internal site identifiers pointing to their sites offset value.
return array_merge(
parent::getSerializationData(),
array(
+ 'cacheVersion' => self::CACHE_VERSION,
'internalIds' => $this->byInternalId,
'globalIds' => $this->byGlobalId,
)
public function unserialize( $serialization ) {
$serializationData = parent::unserialize( $serialization );
+ $this->cacheVersion = $serializationData['cacheVersion'];
$this->byInternalId = $serializationData['internalIds'];
$this->byGlobalId = $serializationData['globalIds'];
$cache = wfGetMainCache();
$sites = $cache->get( wfMemcKey( 'SiteList' ) );
- if ( is_object( $sites ) ) {
+ if ( is_object( $sites ) && isset( $sites->cacheVersion ) && $sites->cacheVersion === SiteArray::CACHE_VERSION ) {
$this->sites = $sites;
- }
- else {
+ } else {
$this->loadSites();
}
}